import request from '@/utils/request'
import { getPlaid } from '@/utils/auth'

/**
 * 获取更新信息
 * @param addon_name
 * @param app_id
 * @returns {AxiosPromise}
 */
export function getAddonAppUpdateMsg(addon_name, app_id) {
  return request({
    url: '/platform/min_app/upload/getAddonAppUpdateMsg',
    method: 'post',
    data: { addon_name, app_id }
  })
}

/**
 * 更新小程序
 * @param addon_name
 * @param changeLog
 * @param platform_appid
 * @param plaid
 * @returns {AxiosPromise}
 */
export function updateAddonApp(addon_name, changeLog, platform_appid, plaid) {
  return request({
    url: '/platform/min_app/upload/updateAddonApp',
    method: 'post',
    data: { addon_name, changeLog, platform_appid, plaid }
  })
}

/** *********************抖音服务商******************************************/

// 获取小程序版本列表信息
export function getDouyinVersionsByAppId(platform_app_id) {
  return request({
    url: '/platform/min_app/upload/getDouyinVersionsByAppId',
    method: 'post',
    data: { platform_app_id }
  })
}

// 获取新版本信息
export function getDouyinNewVersion(platform_app_id) {
  return request({
    url: '/platform/min_app/upload/getDouyinNewVersion',
    method: 'post',
    data: { platform_app_id }
  })
}

/**
 * 提交代码
 * @param platform_app_id
 * @param desc
 * @returns {AxiosPromise}
 */
export function uploadDouyinVersion(platform_app_id, desc = '') {
  return request({
    url: '/platform/min_app/upload/uploadDouyinVersion',
    method: 'post',
    data: { platform_app_id, desc }
  })
}

// 获取二维码
export function getDouyinQrcode(platform_app_id, version = '') {
  return request({
    url: '/platform/min_app/upload/getDouyinQrcode',
    method: 'post',
    data: { platform_app_id, version }
  })
}

// 提交审核
export function auditDouyinVersion(platform_app_id, data) {
  return request({
    url: '/platform/min_app/upload/auditDouyinVersion',
    method: 'post',
    data: { platform_app_id, data }
  })
}

// 撤回审核
export function revokeAuditDouyinVersion(platform_app_id) {
  return request({
    url: '/platform/min_app/upload/revokeAuditDouyinVersion',
    method: 'post',
    data: { platform_app_id }
  })
}
